<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>人员信息</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="viewer/viewer.min.css" rel="stylesheet" type="text/css" />
<link href="css/font/iconfont.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="layui/jquery.min.js"></script>
<script type="text/javascript" src="viewer/viewer.min.js"></script>
</head>

<body onload="biad()">

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="index.html">首页</a></li>
    <li><a href="#">人员管理</a></li>
    <li><a href="#">基本内容</a></li>
    </ul>
    </div>
    
    <div class="rightinfo">
    
    <div class="tools">
    
    	<ul class="toolbar">
        <li class="add"><a href="personnel_edit.html" target="rightFrame"><span><img src="images/t01.png" /></span>添加</a></li>
        </ul>
    
    </div>
    
    
    <table class="tablelist">
    	<thead>
    	<tr>
        <th>编号</th>
        <th>姓名</th>
        <th>组织</th>
        <th>个人邮箱</th>
        <th>电话</th>
        <th>家庭地址</th>
        <th>身份证号码</th>
        <th>年龄</th>
        <th>性别</th>
        <th>个人简介</th>
        <th>个人主页</th>
        <th>个人名片</th>
        <th>操作</th>
        </tr>
        </thead>
        <tbody>
     
        </tbody>
    </table>
    
   
    <div class="pagin">
    	<div class="message">共<i class="blue">1</i>条记录，当前显示第&nbsp;<i class="blue">1&nbsp;</i>页</div>
        <ul class="paginList">
        <li class="paginItem"><a href="javascript:;"><span class="pagepre"></span></a></li>
        <li class="paginItem current"><a href="javascript:;">1</a></li>
        <li class="paginItem"><a href="javascript:;">2</a></li>
        <li class="paginItem"><a href="javascript:;">3</a></li>
        <li class="paginItem"><a href="javascript:;">4</a></li>
        <li class="paginItem"><a href="javascript:;">5</a></li>
        <li class="paginItem more"><a href="javascript:;">...</a></li>
        <li class="paginItem"><a href="javascript:;">10</a></li>
        <li class="paginItem"><a href="javascript:;"><span class="pagenxt"></span></a></li>
        </ul>
    </div>
    
    
    <div class="tip">
    	<div class="tiptop"><span>提示信息</span><a></a></div>
        
      <div class="tipinfo">
        <span><img src="images/ticon.png" /></span>
        <div class="tipright">
        <p>是否确认删除此信息 ？</p>
        <cite>如果是请点击确定按钮 ，否则请点取消。</cite>
        </div>
        </div>
        
        <div class="tipbtn">
        <input name="" type="button"  class="sure" value="确定" />&nbsp;
        <input name="" type="button"  class="cancel" value="取消" />
        </div>
    
    </div>        
    </div>
    
    	
  <script type="text/javascript">
  
  

  $('.tablelist tbody tr:odd').addClass('odd');
  
$(document).ready(function(){
  $(".click").click(function(){
  $(".tip").fadeIn(200);
  });
  
  $(".tiptop a").click(function(){
  $(".tip").fadeOut(200);
});

  $(".sure").click(function(){
  $(".tip").fadeOut(100);
});

  $(".cancel").click(function(){
  $(".tip").fadeOut(100);
});
});

function biad(){ 
	$.ajax({
		url:"/Servicing/person/findPersonInfo",
		type:"POST",
		dataType:"json",
		async:false,
		success:function(result){
			var obj=result;			
			$.each(obj,function(key,value){
 				var se="";
				if(value.personSex===1){
					se="男";
				}else if(value.personSex===2){
					se="女";
				}else{
					se="default";
				}	
				var cardNum=value.personCard;
				var idCard = cardNum.replace(/^(.{6})(.{8})(.*)$/, '$1********$3');
				var str="";
			str="<tr><td>"+value.personCode+"</td><td>"+value.personName+"</td><td>"+
			value.personCompany+"</td><td>"+value.personEmail+"</td><td>"+value.personPhonenumber+"</td>"+
			"<td>"+value.personAddress+"</td><td>"+idCard+"</td><td>"+value.personAge+"</td>"+
			"<td>"+se+"</td><td>"+value.personTitle+"</td><td><a href='http://"+value.personWebsite+"'>"+value.personWebsite+"</a></td>"+
			"<td><img style='width:100px;height:100px' src='data:image/png;base64,"+value.personVcard+"' /></td><td><a href='javascript:update("+value.id+")'><i style='font-size: 24px;color:blue'title='修改' class='iconfont icon-caozuorizhi'></i></a>|<a href='javascript:dele("+value.id+")'>"+
			"<i style='font-size: 24px;color:red'title='删除' class='iconfont icon-shanchu_'></i></a></td></tr>";
			$('.tablelist').append(str);
		})
		$('.tablelist').viewer();
	}
})
}


//编辑
function update(id){
	if(id!=null&&id!=""){
		window.location.href="personnel_edit.html?hid="+id;
	}
}
//删除
function dele(id){
	$(".tip").fadeIn(200);
	$(".sure").click(function(){
		if(id!=null&&id!=""){
			var uid=id;
			var jsonstr={"id":uid};
			$.ajax({
				url:"/Servicing/person/deletePerson",
				data:jsonstr,
				dataType:"text",
				type:"POST",
				success:function(result){
					if(result=="success"){
						 alert("人员删除成功！");
						 $(".tip").fadeOut(100);
						 location.reload();
					}else{
						 alert("人员删除失败！");
						 $(".tip").fadeOut(100);
					}
				}
			})
		}
	})
}

//用户信息生成二维码
function createQrCode(id){
	var results=findUserById(id);//获取查询出的json对象
	var fileName="";
	$.each(results,function(key,value){
		fileName=value.userName;
	})
	var newstr=JSON.stringify(results);//将查询出来的对象信息转为字符串
	var jsonstr={"newstr":newstr,"fileName":fileName};
	//将要存储的用户信息请求后台生成二维码
	$.ajax({
		url:"/Servicing/qr/createUserQrCode",
		data:jsonstr,
		dataType:"text",
		type:"POST",
		success:function(msg){
			if(msg!=null){
				alert("二维码生成成功！");
			}else{
				alert("二维码生成失败！");
			}
		}
	})
}
//根据用户ID查查对应的用户数据
function findUserById(id){
	var hid=id;
		var values="";
		var jsonstr={"id":hid};
		$.ajax({
			url:"/Servicing/user/findUserById",
			data:jsonstr,
			dataType:"json",
			type:"POST",
			async:false,
			success:function(result){
				values=result;
			}
		
		})
		return values;
}
</script>
</body>
</html>
